home *** CD-ROM | disk | FTP | other *** search
- Path: news.compuserve.com!newsmaster
- From: 100754.2730@compuserve.com (Martin Aupperle)
- Newsgroups: comp.lang.c++
- Subject: Q: Returning a reference
- Date: Wed, 10 Jan 1996 08:11:19 GMT
- Organization: CompuServe Incorporated
- Message-ID: <4cvsm2$5ig@dub-news-svc-4.compuserve.com>
- NNTP-Posting-Host: dd67-016.compuserve.com
- X-Newsreader: Forte Free Agent v0.56
-
- Borland C++ V4.5 does not allow to return a reference to a local
- variable:
-
- int &doIt() {
-
- int i = 7;
- return i; // syntax error
- }
-
- I remember that I once had a compiler that did allow it (it gave me
- only a warning).
- Which one is right? I think that it should be an error because after
- the function has terminated, the reference has no data object it is
- bound to any more.
-
- Martin
-
-
- -----------------------------------
- Signatures are a waste of bandwidth
- -----------------------------------
-
-